package com.wn.base.hessian;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @FileName: HessianTest
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2021/1/11 - 12:29
 * @Version: V1.0
 * @Company: 东方微银科技（北京）有限公司
 */
public class HessianTest {

    public static void main(String[] args) {
        String text = "aa aaa aa a aaa aaa";
        String[] split = text.split(" ");
        String join = String.join("|", Arrays.asList(split));
        System.out.println(join);
        String collect = Arrays.stream(split).collect(Collectors.joining(" "));
        System.out.println(collect);
        // test(text);
    }

    public static String test(String text) {
        String[] split = text.toLowerCase().split(" ");
        Map<Integer, List<String>> collect = Arrays.stream(split).collect(Collectors.groupingBy(String::length));
        System.out.println(collect);
        String str = collect.values().stream().map(x -> String.join(" ", x)).collect(Collectors.joining(" "));
        System.out.println(str);
        return str;
    }

    // public static void main(String[] args) {
    //     // MultiValueMap 一个 key 可以对应多个 value
    //     MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
    //     map.add("name", "小明");
    //     map.add("name", "小红");
    //     System.out.println(map.toString());
    //
    //     Map<String, List<String>> map1 = map;
    //     System.out.println(map1.get("name"));
    // }

    // public static void main(String[] args) throws IOException {
    //     Student stu = new Student();
    //     stu.setAddress("屋子科");
    //     stu.setName("ymz");
    //
    //     ByteArrayOutputStream os = new ByteArrayOutputStream();
    //     Hessian2Output output = new Hessian2Output(os);
    //     output.writeObject(stu);
    //     output.close();
    //
    //     Student.hobby = "drink";
    //
    //     ByteArrayInputStream bis = new ByteArrayInputStream(os.toByteArray());
    //     Hessian2Input input = new Hessian2Input(bis);
    //     Student student = (Student) input.readObject();
    //     System.out.println(student.getAddress());
    //     System.out.println(student.getName());
    // }
}
